package com.fangfaze.java.hcwork.liveLifeCycle.utils;

import com.fangfaze.java.hcwork.liveLifeCycle.entity.MessageBody;
import com.google.gson.Gson;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MessageSender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(MessageBody messageBody) {
        String json = new Gson().toJson(messageBody);
        System.out.println("Sender : " + json);
        rabbitTemplate.convertAndSend("topic", json);
    }

}
